package com.example.bookstore.utils;


import com.example.bookstore.enums.ResultEnum;
import com.example.bookstore.vo.ResultVO;

public class ResultVOUtil {

    /*
     *@param object
     *@return 有参数的成功结果
     */
    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(1);
        resultVO.setMessage("成功");
        resultVO.setData(object);
        return resultVO;
    }

    /*
     *@return 返回无参结果
     */
    public static ResultVO success() {
        return success(null);
    }

    public static ResultVO error(ResultEnum resultEnum) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(resultEnum.getCode());
        resultVO.setMessage(resultEnum.getMessage());
        return resultVO;
    }

}
